package com.orhon.smartcampus.modules.material.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import com.orhon.smartcampus.modules.base.entity.Schools;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@EqualsAndHashCode
@Entity
@Table(name = "material_site", schema = "smartcloud", catalog = "")
public class Site {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "site_use", nullable = true)
    private Integer siteUse;
    @Column(name = "site_area", nullable = true, precision = 0)
    private Float siteArea;
    @Column(name = "site_right_use", nullable = true)
    private Integer siteRightUse;
    @Column(name = "site_tel", nullable = true, length = 11)
    private String siteTel;
    @Column(name = "created_at", nullable = true)
    private Date createdAt;
    @Column(name = "created_by", nullable = true)
    private Integer createdBy;
    @Column(name = "updated_at", nullable = true)
    private Date updatedAt;
    @Column(name = "updated_by", nullable = true)
    private Integer updatedBy;
    @Column(name = "deleted_at", nullable = true)
    private Date deletedAt;
    @Column(name = "site_name", nullable = true)
    private String siteName;
    @Column(name = "site_manager", nullable = true)
    private String siteManager;


    @ManyToOne
    @JoinColumn(name = "campus_id", referencedColumnName = "id")
    @Where(clause = "ISNULL(deleted_at)")
    @NotFound(action= NotFoundAction.IGNORE)
    private Campus materialCampusByCampusId;

    @ManyToOne
    @JoinColumn(name = "school_id", referencedColumnName = "id")
    @Where(clause = "ISNULL(deleted_at)")
    @NotFound(action=NotFoundAction.IGNORE)
    private Schools baseSchoolsBySchoolId;
}
